package com.dcloud.core.client;

import com.dcloud.core.client.rdbms.absRdbms.AbsRdbmsClient;
import com.dcloud.core.client.rdbms.absRdbms.AbsRdbmsConnFactory;
import com.dcloud.core.source.ISource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @ClassName : DorisClient
 * @Description : doris执行客户端
 * @Author : shijf
 * @Date: 2024-03-28 10:28
 */
@Component("DORIS")
@Slf4j
public class DorisClient extends AbsRdbmsClient {

    @Override
    public List<Map<String, Object>> execQueryWithLimit(ISource defineSource, String taskSql, Long offset, Long rows) {
        if(offset == null){
            offset = 0l;
        }
        String newTaskSql = "select * from ( "+taskSql+" ) a  limit " + offset +"," + rows;
        return super.execQuery(defineSource,newTaskSql);
    }

    @Override
    protected AbsRdbmsConnFactory getConnFactory() {
        return new DORISRdbmsConnFactory();
    }
}
